package com.lakeworks.processor.base;

import com.alibaba.fastjson.JSONObject;
import com.lakeworks.common.domain.base.event.IssueEvent;
import com.lakeworks.domain.TktProcess;
import org.slf4j.Logger;

import static org.slf4j.LoggerFactory.getLogger;

public abstract class AbstractIssueProcessor<E extends IssueEvent> implements IssueProcessor<E> {

    protected final Logger logger = getLogger(getClass());

    @Override
    public TktProcess apply(
            E event
    ) {
        TktProcess build = TktProcess.builder()
                .event(JSONObject.toJSONString(event))
                .eventVo(event)
                .processor(this.getName())
                .version(0)
                .comment(event.getComment())
                .build();
        build.setCreateBy(event.getOperator());
        build.setModifyBy(event.getOperator());
        return build;
    }
}
